package com.xbl.mail.task;

import com.xbl.mail.entity.MailSend;
import com.xbl.mail.service.MailSendService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by admin on 2017/6/5.
 */
@Component
public class RetryTask {

    private static Logger LOGGER = LoggerFactory.getLogger(RetryTask.class);
    @Autowired
    private MailSendService mailSendService;

    @Scheduled(initialDelay = 5000, fixedDelay = 6000)
    public void retry() {
        List<MailSend> list = mailSendService.queryDraftList();
        System.out.println("列表长度："+list.size());
        for (MailSend mailSend : list) {
            mailSendService.sendRedis(mailSend);
        }
    }
}
